package com.atguigu.config;

import com.atguigu.interceptors.MyInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * projectName: com.atguigu.config
 *
 * @author: 赵伟风
 * description: springmvc框架的配置类 。 配置拦截器
 * WebMvcConfigurer - springmvc框架配置类的特殊限制接口 -》 规定mvc各种特别组件的配置方式 包含拦截器
 */
@Configuration
public class SpringMvcConfiguration implements WebMvcConfigurer {

    //常规的组件对象 -》 加入到了ioc容器！
    //拦截器不仅仅需要添加到ioc容器，配置拦截和放行规则！！
    @Autowired
    private MyInterceptor myInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor).
                addPathPatterns("/**").excludePathPatterns("/ergouzi").order(10);
    }
}
